package com.example.container.sleep;

/**
 * Created by ZMJ on 2019/12/29.
 */
public class SleepRunnable implements Runnable {

    private Object object = new Object();

    @Override
    public void run() {

        synchronized (object) {

            while (true) {
                System.out.println(Thread.currentThread().getName() + "要睡觉了，但我不会放掉object的锁");
                try {
                    Thread.currentThread().sleep(50);//睡5秒
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
    }


}
